package com.student.demo.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import com.student.demo.entity.Teacher;
import com.student.demo.repository.TeacherRepository;

@Service
public class TeacherService {

	@Resource
	private TeacherRepository teacherRepository;
	
	//查询所有的教师全部信息 使用了分页查询
	public List<Teacher> findAll(Integer page,int i) {
		PageRequest p = new PageRequest(page, i);
		 Page<Teacher> findAll = teacherRepository.findAll(p);
		return findAll.getContent();
	}
	
	//添加老师的基本信息
	public Teacher addTeacher(Teacher teacher) {
		return teacherRepository.save(teacher);
	}
	
	//查询老师的id信息
	public Teacher findByBid(Integer id) {
		return teacherRepository.findByBId(id);
	}
	
	
}
